/**
 * <p>Title: SequenceProducer</p>
 * <p>Description: product sequence</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2016</p>
 * <p>Company: Baosight Software</p>
 * @author Huang Zhongwei
 * @version 1.0
 * <pre>Histroy:
 *       2016-9-20  Huang Zhongwei  Create
 *</pre>
*/
package cn.jhg.account.util;

import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cn.jhg.account.persist.SequenceDao;

@Component
@Scope("singleton")
public class SequenceProducer {

	@Resource
	private SequenceDao sequenceDao;
	
	//获取当前最大ID值
	public int currval(String name){

		int num=sequenceDao.currval(name);
		return num;
	}
	//获取ID最大值+1，赋予新增的ID
	public synchronized int nextval(String name){
		
		int num=sequenceDao.getNextval(name);
		sequenceDao.nextval(name);
		return num;
}
}

